/**
 * KopsoxFramework
 * Copyright (C) 2010 Free Software Foundation, Inc. <http://fsf.org/>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.kopsox.validation;

import java.io.Serializable;
import java.util.List;

import org.kopsox.comm.message.ErrorMessage;
import org.kopsox.comm.message.ValueMessage;
import org.kopsox.general.priority.Prioritized;
import org.kopsox.validation.handler.ValidationErrorHandler;

/**
 * Standardinterface for Validators
 *
 * @author Konrad Renner
 *
 */
public interface Validator extends Serializable, Comparable<Validator>, Prioritized {

	/**
	 * Validates a given value
	 * 
	 * @param value - ValueMessage
	 * @return boolean
	 */
	public boolean validateValueMessage(ValueMessage value);
	
	/**
	 * Delegates the Errors to ErrorHandlers
	 */
	public void delegateErrorsToHandlers();
	
	/**
	 * Gets the Error-List which was created by the validateValue-Method
	 * 
	 * @return List<ErrorMessage>
	 */
	public List<ErrorMessage> getValidationErrors();
	
	/**
	 * Registers a Handler
	 * 
	 * @param handler - ValidationErrorHandler
	 */
	public void addHandler(final ValidationErrorHandler handler);
	
	/**
	 * Removes a Handler
	 * 
	 * @param handler - ValidationErrorHandle
	 */
	public void removeHandler(final ValidationErrorHandler handler);
	
	/**
	 * Returns true if the Validator is a 'Show-Stopping'-Validator.<br>
	 * A 'Show-Stopping'-Validator is an Validators which stops the validation process, if he fails.<br>
	 * This means, that after this Validator no other Validator is called, if the method 'validateValueMessage' returns false!
	 * 
	 * @return boolean
	 */
	public boolean isShowStoppingValidator();
}
